#ifndef __PROBER_DEV_H_
#define __PROBER_DEV_H_

struct probe_cmdpkt_t
{
	unsigned char head[2];
	unsigned char address;//
	unsigned char cmd;//c1c2c3c4ad
	unsigned short duration;//
	unsigned char tail;
}__attribute__((packed));

struct probe_ackpkt_t
{
	unsigned char head[2];
	unsigned char address;//
	unsigned char cmd;//c1c2c3c4ad
	unsigned short distance;//
	unsigned char tail;
}__attribute__((packed));

#define SENSOR_STAT_OFFLINE 0x0
#define SENSOR_STAT_NOCAR 0x1
#define SENSOR_STAT_HAVECAR 0x2
#define SENSOR_STAT_ERROR 0x3
#define SENSOR_STAT_IDLE 0x4
#define SENSOR_STAT_BUSY 0x8


#define PROBER_DEV_STAT_INIT 0
#define PROBER_DEV_STAT_WAIT 1
#define PROBER_DEV_STAT_READY 2
#define PROBER_DEV_STAT_CREAT 3
#define PROBER_DEV_STAT_RUN 4
#define PROBER_DEV_STAT_IDLE 250

#define PROBER_IO_NUM 8


typedef struct sensor_s
{
	int dev_type;
	int stat;
	int old_stat;
	int high;
	int sensor_id;
	int sensor_type;
	int io_addr;
	int host_addr;
	struct list_head sensor_list;
}S_SENSOR, *PS_SENSOR;

#define PARK_PROBER_SEARCH_PORT 12000
#define PARK_PROBER_LISTEN_PORT 12001


#define PARK_PROBER_ONLINE 1
#define PARK_PROBER_OFFLINE 0
#define PARK_PROBER_MAX_SENSOR 50
#define SENSOR_WHETHER_HAVE_CAR 80
#define PROBER_STAT_IDLE_TIMEOUT 15

typedef struct sensor_trap_a
{
	int sensor_id;
	int sensor_stat;
}S_SENSOR_TRAP, *PS_SENSOR_TRAP;

#define SENSOR_TRAP_TYPE_STATCHANGE 0x1
#define SENSOR_TRAP_TYPE_DATAREQ 0x2
#define SENSOR_TRAP_TYPE_REQ 0x3

typedef struct sensor_trap_head_a
{
	int config_id;
	int trap_type;
	int prober_id;
	char prober_addr[20];
	int sensor_num;
	char sensor[0];
}S_SENSOR_TRAP_HEAD, *PS_SENSOR_TRAP_HEAD;

typedef struct park_prober_head_s
{
	int config_id;
	int probr_id;
	char agent_addr[20];
	int sensor_num;
	char sensor[0];
}S_PARK_PROBER_HEAD, *PS_PARK_PROBER_HEAD;


typedef struct prober_dev_t
{
	int stat;
	int oldstat;
	NET_HANDLE_T stNet;
	NET_SOCKET_T listen_fd;
	NET_SOCKET_T connect_fd;
	pthread_t pid;
	int cur_config_id;
	int prober_id;
	char agent_addr[20];
	int sensor_num;
	PS_SENSOR pstSensor_a;
	char *buff;
	char *cur_buff;
	sem_t prober_sem;
	io_info_t *pio;
	int trap_num;
	S_SENSOR_TRAP stSensor_trap_a[PARK_PROBER_MAX_SENSOR];
}S_PROBER_DEV, *PS_PROBER_DEV;

S_PROBER_DEV stProber_dev;


#endif
